<?php


namespace App\Http\Controllers;

use App\Models\Guide;

class GuideController extends Controller
{
    /*
     * @api get /course-api/guides 精彩绘本列表
     * @version 0.0.1
     * @group web
     *
     * @response 200 正常结果 {
     *  "code":0,
     *  "msg":"",
     *  "data":[{
     *    "title[标题]": "精彩绘本抢先看",
     *    "cover[封面]": "http://fox-static.oss-cn-shanghai.aliyuncs.com/course/26/e6/266e26e9ca1e4d9412ff22f43b2c85e6.png",
     *    "pages[页面]": [{
     *       "image[图片]": "http://fox-static.oss-cn-shanghai.aliyuncs.com/course/43/5e/4391ce33c7bc517d64f7fa98dfd8225e.png",
     *          "sentence[句子信息]": {
     *          "text[文本]": "djlsj lsjdlsjd lsjd lsjd",
     *          "audio[音频]": "http://fox-static.oss-cn-shanghai.aliyuncs.com/course/63/9c/63ffae320c311d29d6457792a248fa9c.ogg"
     *          }
     *      }]
     *   }]
     * }
     */
    public function index()
    {
        $guidesObj = Guide::where('is_published', 1)->orderBy('level', 'asc')->get();
        $guides = [];
        /** @var Guide $guideObj */
        foreach ($guidesObj as $guideObj) {
            $guides[] = $guideObj->getMetadata();
        }
        return $this->sendSuccessJson($guides);
    }
}